<template>
  <div class="content-main">
    <div v-show="!toExamisShow" class="register-content">
      <div class="main-top">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-card shadow="never" class="userModel">
              <div
                  style="
                  width: 100%;
                  display: flex;
                  justify-content: space-between;
                "
              >
                <!-- <div class="user-img">
                                                     <el-avatar shape="square" :size="60" :src="Avatar ? Avatar:squareUrl"></el-avatar>
                  <img
                    style="display:none;"
                    width="80px"
                    height="99.43px"
                    :src="
                      person.photo
                        ? person.photo + '?' + new Date()
                        : 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png'
                    "
                  />
                </div> -->
                <div class="user">
                  <div class="user-name">
                    <p class="name">
                      {{ person.name }}
                      <i
                          :class="
                          person.gender_display == '男'
                            ? 'iconfont icon-xingbienan'
                            : 'iconfont icon-xingbienan-copy'
                        "
                      ></i>
                    </p>
                  </div>
                  <div style="margin-top: 10px">
                    <p>
                      学员ID: {{ person.user }}
                    </p>
                  </div>
                  <div style="margin-top: 10px">
                    <p>
                      <i class="iconfont icon-shouji"></i>{{ person.phone }}
                    </p>
                  </div>
                </div>
                <el-button style="height: 30px" @click="personMessageIsShow = !personMessageIsShow" size="small">展开</el-button>
              </div>
              <div v-show="personMessageIsShow" class="user-describe">
                <div>
                  <i class="iconfont icon-zhengjianleixing"></i>
                  {{ person.card_type_display }}
                </div>
                <div>
                  <i class="iconfont icon-shenfenzheng"></i>
                  {{ person.card_id | hideMiddle}}
                </div>
                <div>
                  <p>
                    <i class="iconfont icon-shengriyingxiao"></i>
                    {{ person.birthday }}
                  </p>
                </div>
                <!--                <div>-->
                <!--                  <i class="iconfont icon-youxiang"></i> {{ person.email }}-->
                <!--                </div>-->
                <!--                <div>-->
                <!--                  <i class="iconfont icon-zhuzhi_chengshi"></i>-->
                <!--                  {{ person.address }}-->
                <!--                </div>-->
              </div>
            </el-card>
            <div class="athor">
              <el-card
                  v-if="
                  person.hig_edu
                "
                  shadow="never"
                  class="school-content"
              >
                <div>
                  <div class="title" style="display: flex;justify-content: space-between">
                    <div>学历信息</div>
                    <el-button size="small" @click="hig_eduIsShow = !hig_eduIsShow">展开</el-button>
                  </div>
                  <div v-show="hig_eduIsShow" class="content">
                    <p v-if="person.school">
                      学校: <span>{{ person.school }}</span
                    ><span class="end"></span>
                    </p>
                    <p v-if="person.hig_edu">
                      最高学历: <span>{{ person.hig_edu }}</span>
                    </p>
                    <p v-if="person.major">
                      专业: <span>{{ person.major }}</span>
                    </p>
                    <p v-if="person.grad_time">
                      毕业年份: <span>{{ person.grad_time.split("-")[0] + "年" + person.grad_time.split("-")[1]+"月" }}</span>
                    </p>
                  </div>
                </div>
              </el-card>
              <el-card shadow="never" class="work-content">
                <div>
                  <div class="title" style="display: flex;justify-content: space-between">
                    <div>工作信息</div>
                    <el-button size="small" @click="workMessageIsShow = !workMessageIsShow">展开</el-button>
                  </div>
                  <div v-show="workMessageIsShow" class="content">
                    <p>
                      单位名称:
                      <span v-if="person.com_name">{{ person.com_name }}</span>
                    </p>
                    <p>
                      行业类型:
                      <span v-if="person.ind_type_display">{{ person.ind_type_display }}</span>
                    </p>
                    <p>
                      单位类型:
                      <span v-if="person.com_type_display">{{ person.com_type_display }}</span>
                    </p>
                    <p>
                      职务:
                      <span v-if="person.work_duty" v-text="person.work_duty.split('#')[0]"></span>
                    </p>
                    <p v-if="person.work_age">
                      从事薪酬管理（含薪税服务）工作年限（含实习经历）: <span>{{ person.work_age }}</span
                    >年
                    </p>
                    <p v-if="person.email">
                      电子邮箱: <span>{{ person.email }}</span
                    >
                    </p>
                    <p>
                      工作区域: <span>{{ person.province ? person.province : '' }}{{ person.city ? person.city:'' }}{{ person.dis ? person.dis : '' }}</span
                    >
                    </p>
                    <p v-if="person.cert_display">
                      相关资质或证书: <span>{{ person.cert_display }}</span>
                    </p>
                  </div>
                </div>
              </el-card>
            </div>
          </el-col>
          <el-col :span="10">
            <el-card shadow="never" class="informModel">
              <div slot="header" class="inform">
                <span>公告通知</span>
                <el-button
                    v-show="false"
                    style="float: right; padding: 3px 0"
                    type="text"
                >更多+
                </el-button>
              </div>
              <div
                  class = "notilist"
                  v-for="item in noticeList"
              >
                <span href="#" style="display: flex;
    justify-content: space-between;
    align-items: center;" @click="showNoti(item.title)"><span>{{ item.title }}</span> <span>{{ item.add_time.split(' ')[0] }}</span></span>
              </div>
              <!-- <el-empty description="暂无通知" :image-size="50"></el-empty> -->
              <el-dialog
                  :title="notice.title"
                  :visible.sync="notiListDialogVisible"
                  width="40%"
                  center>
                <div v-html="notice.text">

                </div>
                <p style="text-align:right;width:100%;">{{notice.add_time ? notice.add_time.split(' ')[0] : ''}}</p>
                <span slot="footer" class="dialog-footer">
                  <el-button @click="notiListDialogVisible = false">取 消</el-button>
                  <el-button type="primary" @click="notiListDialogVisible = false">确 定</el-button>
                </span>
              </el-dialog>
            </el-card>
          </el-col>
          <el-col :span="8">
            <el-card shadow="never" class="flowModel">
              <div slot="header" class="flow">
                <span>报名流程</span>
                <el-button
                    style="float: right"
                    size="mini"
                    @click="registerVisible = true"
                >添加报名
                </el-button>
              </div>
              <div class="flow-describe">
                <p>1.报名网址：https://ccw.ptaedu.cn/</p>
                <p>2.点击注册，输入证件号码进行实名认证</p>
                <p>3.实名认证成功后输入机构代码提交填写报名信息</p>
                <p>4.提交后进入用户个人中心，等待审核</p>
                <p>6.审核通过开通学习账号</p>
                <p>7.满足学习课时后可以点击报考</p>
                <p>8.填写信息后提交进入签署合同页面</p>
                <p>9.审核通过生成准考证和查看合同</p>
              </div>
            </el-card>
            <el-dialog
                class="add-reigster"
                title="培训报名"
                :visible.sync="registerVisible"
                width="70%"
                :before-close="addRegisterClose"
            >
              <RegistrationAgreement @toRegister="toRegister" v-if="model === 'RegistrationAgreement'"></RegistrationAgreement>
              <register-form
                  v-else-if="model === 'addRegister'"
                  ref="registerForm"
                  :isNotFirstRegister="true"
                  @registerForm="addOrg"
                  :registerParams="profile"
                  style="text-align: left; display: flex; justify-content: center"
              ></register-form>
            </el-dialog>
          </el-col>
          <el-col :span="18" class="athor-right">
            <el-dialog title="编辑信息" :visible.sync="drawer" width="70%">
              <div style="display: flex; justify-content: center;text-align: left">
                <el-form
                    label-position="top"
                    ref="updateForm"
                    :model="form"
                    :rules="formRules"
                    label-width="100px"
                >
                  <div>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item :required="true" label="报读的科目（级别）">
                          <el-input
                              size="small"
                              :disabled="true"
                              v-model="form.course.name"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col v-if="form.exam_org" :span="16">
                        <el-form-item :required="true" prop="exam_org" align="left" label="是否属于补考">
                          <el-tag size="small">{{form.make_up_count > 0 ? '是':'否'}}</el-tag>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item :required="true" label="您报读的培训机构">
                          <el-input
                              size="small"
                              :disabled="true"
                              v-model="form.org.org_name"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col v-if="form.exam_org" :span="16">
                        <el-form-item :required="true" label="您报考的培训机构">
                          <el-input
                              size="small"
                              :disabled="true"
                              v-model="form.exam_org.org_name"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20" v-if="form.state_code > 4">
                      <el-col :span="8">
                        <el-form-item prop="exam_city" label="考试形式">
                          <el-select
                              size="small"
                              v-model="form.exam_city"
                              placeholder="请选择考试形式"
                          >
                            <el-option
                                v-for="item in examCityOptions"
                                :key="item.id"
                                :label="item.exam_city"
                                :value="item.exam_city"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="16">
                        <el-form-item prop="exam_date" label="考试时间">
                          <el-select
                              size="small"
                              v-model="form.exam_date"
                              placeholder="请选择考试时间"
                          >
                            <el-option
                                v-for="item in examDateOptions"
                                :key="item.id"
                                :label="item.exam_date"
                                :value="item.exam_date"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item prop="name" label="学员姓名">
                          <el-input
                              size="small"
                              :disabled="true"
                              v-model="form.name"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="16">
                        <el-form-item :required="true" label="性别">
                          <el-radio-group
                              :disabled="userDisable"
                              v-model="form.gender"
                          >
                            <el-radio label="m">男</el-radio>
                            <el-radio label="f">女</el-radio>
                          </el-radio-group>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item prop="last_py" label="姓拼音">
                          <el-input
                              onblur="this.value=this.value.toUpperCase()"
                              size="small"
                              v-model="form.last_py"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item prop="first_py" label="名拼音">
                          <el-input
                              onblur="this.value=this.value.toUpperCase()"
                              size="small"
                              v-model="form.first_py"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item prop="card_type" label="证件类型">
                          <el-select
                              size="small"
                              :disabled="userDisable"
                              v-model="form.card_type"
                              placeholder="请选择证件类型"
                          >
                            <el-option
                                v-for="item in cardOptions"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id"
                            ></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="8">
                        <el-form-item prop="card_id" label="证件号码">
                          <el-input
                              size="small"
                              :disabled="true"
                              v-model="form.card_id"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item prop="birthday" label="出生日期">
                          <el-date-picker
                              style="width: auto"
                              size="small"
                              :disabled="userDisable"
                              format="yyyy 年 MM 月 dd 日"
                              value-format="yyyy-MM-dd"
                              placeholder="选择日期"
                              v-model="form.birthday"
                          ></el-date-picker>
                        </el-form-item>
                      </el-col>
                      <el-col :span="16">
                        <el-form-item prop="com_name" label="单位名称">
                          <el-input
                              size="small"
                              v-model="form.com_name"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="24">
                        <el-form-item prop="province" label="工作区域">
                          <el-cascader
                              style="width: 100%!important;"
                              size="small"
                              :options="areaOptions"
                              v-model="selectedOptionsUpdate"
                              @change="addressChange"
                          >
                          </el-cascader>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item prop="hig_edu" label="最高学历">
                          <el-select
                              size="small"
                              :disabled="true"
                              v-model="form.hig_edu"
                              placeholder="最高学历"
                          >
                            <el-option
                                label="硕士研究生"
                                value="硕士研究生"
                            ></el-option>
                            <el-option label="博士" value="博士"></el-option>
                            <el-option label="本科" value="本科"></el-option>
                            <el-option label="大专" value="大专"></el-option>
                            <el-option
                                label="中专/职技校"
                                value="中专/职技校"
                            ></el-option>
                            <el-option label="高中" value="高中"></el-option>
                            <el-option label="其他" value="其他"></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col v-if="form.grad_time" :span="8">
                        <el-form-item prop="grad_time" label="毕业年份">
                          <el-date-picker
                              size="small"
                              style="width: 100%"
                              format="yyyy 年 MM 月"
                              :clearable="false"
                              value-format="yyyy-MM-dd"
                              type="month"
                              placeholder="选择日期"
                              v-model="form.grad_time"
                          ></el-date-picker>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item prop="major" label="相关专业">
                          <el-select
                              size="small"
                              :disabled="true"
                              v-model="form.major"
                              placeholder="相关专业"
                          >
                            <el-option label="人力资源管理" value="人力资源管理"></el-option>
                            <el-option label="工商管理" value="工商管理"></el-option>
                            <el-option label="行政管理" value="行政管理"></el-option>
                            <el-option label="会计" value="会计"></el-option>
                            <el-option label="财政、税务" value="财政、税务"></el-option>
                            <el-option label="财政管理" value="财政管理"></el-option>
                            <el-option label="其他" value="其他"></el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="16">
                        <el-form-item :required="true" prop="cert" label-width="120px" label="相关资质或证书">
                          <el-select
                              size="small"
                              :disabled="true"
                              style="width: 420px; margin-right: 20px"
                              v-model="form.cert"
                              placeholder="请选择"
                          >
                            <el-option
                                v-for="item in certDisplayOptions"
                                :key="item.id"
                                :label="item.name"
                                :value="item.id"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item prop="ind_type" label="行业类型">
                          <el-select
                              size="small"
                              v-model="form.ind_type"
                              placeholder="请选择行业类型"
                          >
                            <el-option
                                v-for="item in ind_typeList"
                                :key="item.value"
                                :label="item.name"
                                :value="item.value"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="16">
                        <el-form-item prop="com_type" label="单位类型">
                          <el-select
                              style="width: 420px; margin-right: 20px"
                              size="small"
                              v-model="form.com_type"
                              placeholder="请选择单位类型"
                          >
                            <el-option
                                v-for="item in com_typeList"
                                :key="item.value"
                                :label="item.name"
                                :value="item.value"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item prop="email" label="电子邮箱">
                          <el-input
                              size="small"
                              v-model="form.email"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="16">
                        <el-form-item prop="work_duty" label="职务">
                          <el-select
                              style="width: 420px; margin-right: 20px"
                              size="small"
                              :disabled="true"
                              v-model="form.work_duty"
                              placeholder="请选择职务"
                          >
                            <el-option
                                v-for="item in work_dutyList"
                                :key="item.value"
                                :label="item.name"
                                :value="item.value"
                            >
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">
                      <el-col :span="8">
                        <el-form-item :required="true" prop="phone" label="手机号码">
                          <el-input
                              size="small"
                              :disabled="true"
                              v-model="form.phone"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="16">
                        <el-form-item prop="work_age" label-width="auto" label="从事薪酬管理（含薪税服务）工作年限（含实习经历）">
                          <el-input
                              size="small"
                              type="number"
                              :disabled="true"
                              v-model="form.work_age"
                          ></el-input>
                        </el-form-item>
                      </el-col>
                    </el-row>
                    <el-row :gutter="20">

                    </el-row>
                    <el-form-item class="updateButton">
                      <el-button size="small" type="primary" @click="editContent"
                      >立即修改</el-button
                      >
                      <el-button size="small" @click="editHandleClose"
                      >取消</el-button
                      >
                    </el-form-item>
                  </div>
                </el-form>
              </div>
            </el-dialog>
            <div class="exam">
              <el-card
                  v-for="item in profile"
                  shadow="never"
                  class="examModel"
                  :key="item.id"
              >
                <el-row :gutter="20">
                  <div style="width:100%;display: flex;justify-content: space-between;">
                    <div style="display:flex;line-height:28px;">
                      <div style="font-size:17px;font-weight: 600;margin-right: 20px;">
                        {{ item.course.name }}
                      </div>
                      <el-button
                          v-if="item.contract_id"
                          size="mini"
                          @click="lookTransation(item.contract_id)"
                      >
                        查看报考确认书
                      </el-button>
                      <el-button
                          :disabled="
                      item.state_code < 3 ||
                      (item.state_code < 7 && item.exam_date)
                        ? false
                        : true
                    "
                          v-if="item.contract_id && item.state_code < 8"
                          size="mini"
                          @click="toTransation(item)"
                      >
                        {{item.signed ? '重新编辑并签署确认书':'继续签署确认书'}}
                      </el-button>
                    </div>
                    <div style="display:flex;">
                      <el-button
                          size="mini"
                          :disabled="
                      item.state_code < 3 ||
                      (item.state_code < 7 && item.exam_date)
                        ? false
                        : true
                    "
                          @click="updateExam(item.id)"
                      >编辑
                      </el-button>
                      <div
                          style="margin-left:20px;"
                          v-if="
                    (!item.school && !item.exam_date && item.state_code > 3) ||
                    (item.exam_list[item.exam_list.length - 1] &&
                      item.exam_list[item.exam_list.length - 1]['is_pass'] ===
                        false)
                  "
                      >
                        <el-button size="mini" @click="toExam(item.id)">
                          {{
                            item.exam_list[item.exam_list.length - 1] &&
                            item.exam_list[item.exam_list.length - 1]["is_pass"] ===
                            false
                                ? `${item.make_up_count+1}次补考`
                                : "点击报考"
                          }}
                        </el-button>
                      </div>
                    </div>
                  </div>
                  <el-col :span="10">
                    <div class="left">
                      <div class="content">
                        <p>培训机构: {{ item.org.org_name.split('_')[0] }}（{{item.org.org_code}}）</p>
                        <div v-if="item.org.agreement != '1'">
                          <p v-if="item.gaodun_p != null  ? true : false">
                            学习账号: {{ item.phone }}
                          </p>
                          <p v-if="item.gaodun_p != null ? true : false">
                            学习密码: {{ item.card_id.substring(item.card_id.length-6, item.card_id.length) }}
                          </p>
                          <p v-if="item.state_code > 4">
                            学习地址: <el-link href="https://study.pta-athe.com/" type="primary">国际薪税师学习中心</el-link>
                          </p>
                          <p v-if="item.exp_date == null ? false : true">
                            账号期限: {{ item.exp_date | expDate }} 至 {{item.exp_date | formatDate2}}
                          </p>

                        </div>
                        <!-- <p>
                          购买教程: {{ item.buy_book ? "已购买" : "未购买" }}
                        </p> -->
                        <p v-if="!item.exam_date">
                          审核状态:
                          <span
                              :style="
                              item.state_code == 8
                                ? 'color:green'
                                : 'color:orange'
                            "
                          >{{
                              state_map[item.state_code] == "机构二审待审" &&
                              item.exam_date == null
                                  ? "培训审核完成，待报考"
                                  : state_map[isReject[item.state_code].includes('reject') && item.note.includes('已编辑') ? item.state_code - 1 < 0 ? item.state_code+1:item.state_code -1 :item.state_code ]
                            }}</span
                          >
                        </p>
                      </div>
                    </div>
                  </el-col>
                  <el-col :span="14">
                    <div class="right">
                      <div class="title">
                        <!-- 报考机构:
                        {{
                          item.exam_org
                            ? item.exam_org.org_name
                            : item.org.org_name
                        }}
                        ({{
                          item.exam_org
                            ? item.exam_org.org_code
                            : item.org.org_code
                        }}) -->

                      </div>
                      <div class="content">
                        <p>
                          是否补考: <el-tag size="small">{{(item.exam_list[item.exam_list.length - 1] && item.exam_list[item.exam_list.length - 1].is_pass == false) || item.make_up_count > 0 ? '是':'否'}}</el-tag>
                        </p>
                        <p v-if="item.exam_org">
                          考试机构: {{ item.exam_org.org_name }}({{item.exam_org.org_code}})
                        </p>
                        <p v-if="item.exam_date">
                          考试形式: {{ item.exam_city }}
                        </p>
                        <p v-if="item.exam_date">
                          <!--                          考试时间: {{ detailTime(item,item.course.id,item.exam_date) }}-->
                          考试时间: {{ examTimeList[item.course.id][0].time_detail  }}
                        </p>
                        <p  v-if="item.exam_date">
                          审核状态:
                          <span
                              :style="
                              item.state_code == 8
                                ? 'color:green'
                                : 'color:orange'
                            "
                          >{{
                              state_map[item.state_code] == "机构二审待审" &&
                              item.exam_date == null && item.state_code >=5
                                  ? "培训审核完成，待报考"
                                  : state_map[isReject[item.state_code].includes('reject') && item.note.includes('已编辑') ? item.state_code - 1 < 0 ? item.state_code+1:item.state_code -1 :item.state_code ]
                            }}</span
                          >
                        </p>
                        <p v-if="isReject[item.state_code].includes('reject')">
                          备注信息:
                          <span
                              style="color: red"
                              v-if="isReject[item.state_code].includes('reject')"
                              v-text="item.note.replace('<已编辑>', '')"
                          ></span>
                        </p>
                        <p v-if="item.state_code == 8">
                          <span style="color: green">准考证号: {{ item.exam_code }}</span>
                        </p>
                      </div>
                    </div>
                  </el-col>
                </el-row>

              </el-card>
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="main-bottom">
        <el-row :gutter="20">
          <el-col :span="6" class="athor-left">

          </el-col>

        </el-row>
      </div>
    </div>
    <div v-show="toExamisShow" class="exam animate__animated animate__zoomIn">
      <div class="exam-header">
        <el-card>
          <el-page-header @back="goBack" content="报名考试"> </el-page-header>
        </el-card>

        <userKnow v-if="isExam_or_ExamAgreement_or_userKnow == 'userKnow'" @showExamAgreement="showExamAgreement"></userKnow>
        <el-card  v-if="isExam_or_ExamAgreement_or_userKnow == 'isExam'">
          <el-form
              label-position="top"
              ref="examForm"
              :rules="rules"
              label-width="120px"
              :model="examForm"
          >
            <!-- <el-steps align-center :active="active" finish-status="success">
              <el-step title="步骤 1"></el-step>
              <el-step title="步骤 2"></el-step>
              <el-step title="步骤 3"></el-step>
            </el-steps> -->
            <div style="padding: 20px; text-align: left;width:70%;">
              <!-- v-show="active == 1" -->
              <div>
                <!--                {{examForm}}-->
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item :required="true" label="您报考的科目(级别)">
                      <el-input
                          size="small"
                          :disabled="true"
                          v-model="examForm.course.name"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <!--                    {{examForm.exam_list.is_pass}}-->
                    <el-form-item :required="true" label="是否属于补考">
                      <el-tag type="primary" size="small">{{(examForm.exam_list && examForm.exam_list.is_pass == false) || examForm.make_up_count > 0 ? '是':'否'}}</el-tag>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item :required="true" label="报考机构代码">
                      <el-input
                          size="small"
                          v-model="examForm.exam_org_code"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item :required="true" label="您报读的培训机构">
                      <el-input
                          size="small"
                          :disabled="true"
                          v-model="examForm.org.org_name"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item prop="name" label="考生姓名">
                      <el-input
                          size="small"
                          :disabled="true"
                          v-model="examForm.name"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                      <el-form-item :required="true" label="性别">
                        <el-radio-group
                            :disabled="true"
                            v-model="examForm.gender"
                        >
                          <el-radio label="m">男</el-radio>
                          <el-radio label="f">女</el-radio>
                        </el-radio-group>
                      </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item prop="last_py" label="姓拼音">
                      <el-input
                          onblur="this.value=this.value.toUpperCase()"
                          size="small"
                          v-model="examForm.last_py"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="first_py" label="名拼音">
                      <el-input
                          onblur="this.value=this.value.toUpperCase()"
                          size="small"
                          v-model="examForm.first_py"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item :required="true" label="证件类型">
                      <el-select
                          style="width: 100%"
                          size="small"
                          :disabled="true"
                          v-model="examForm.card_type"
                          placeholder="请选择证件类型"
                      >
                        <el-option
                            v-for="item in cardOptions"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item :required="true" label="证件号码">
                      <el-input
                          style="width: 100%"
                          size="small"
                          :disabled="true"
                          v-model="examForm.card_id"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item :required="true" label="出生日期">
                      <el-date-picker
                          style="width: 100%"
                          size="small"
                          :disabled="true"
                          format="yyyy 年 MM 月 dd 日"
                          value-format="yyyy-MM-dd"
                          placeholder="选择日期"
                          v-model="examForm.birthday"
                      ></el-date-picker>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item prop="com_name" label="单位名称">
                      <el-input
                          size="small"
                          v-model="examForm.com_name"
                      ></el-input>
                    </el-form-item>
                  </el-col>

                </el-row>
                <el-row :gutter="20">

                  <el-col :span="16">
                    <el-form-item prop="province" label="工作区域">
                      <el-cascader
                          style="width: 100%!important;"
                          size="small"
                          clear
                          :options="areaOptions"
                          v-model="selectedOptions"
                          @change="addressChangeExam"
                      >
                      </el-cascader>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item prop="hig_edu" label="最高学历">
                      <el-select
                          style="width: 100%"
                          size="small"
                          :disabled="true"
                          v-model="examForm.hig_edu"
                          placeholder="最高学历"
                      >
                        <el-option
                            label="博士及以上"
                            value="博士及以上"
                        ></el-option>
                        <el-option label="研究生" value="研究生"></el-option>
                        <el-option label="本科" value="本科"></el-option>
                        <el-option label="专科" value="专科"></el-option>
                        <el-option label="其他" value="其他"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col v-if="examForm.grad_time" :span="8">
                    <el-form-item prop="grad_time" label="毕业年份">
                      <el-date-picker
                          size="small"
                          style="width: 100%"
                          type="month"
                          :clearable="false"
                          format="yyyy 年 MM 月"
                          value-format="yyyy-MM-dd"
                          placeholder="选择日期"
                          v-model="examForm.grad_time"
                      ></el-date-picker>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
              <!-- v-show="active == 2" -->
              <div>

                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item prop="major" label="相关专业">
                      <el-select
                          style="width: 100%"
                          size="small"
                          :disabled="true"
                          v-model="examForm.major"
                          placeholder="相关专业"
                      >
                        <el-option label="人力资源管理" value="人力资源管理"></el-option>
                        <el-option label="工商管理" value="工商管理"></el-option>
                        <el-option label="行政管理" value="行政管理"></el-option>
                        <el-option label="会计" value="会计"></el-option>
                        <el-option label="财政、税务" value="财政、税务"></el-option>
                        <el-option label="财政管理" value="财政管理"></el-option>
                        <el-option label="其他" value="其他"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="16">
                    <el-form-item prop="cert" label="相关资质或证书">
                      <el-select
                          size="small"
                          :disabled="true"
                          style="width: 420px; margin-right: 20px"
                          v-model="examForm.cert"
                          placeholder="请选择"
                      >
                        <el-option
                            v-for="item in certDisplayOptions"
                            :key="item.id"
                            :label="item.name"
                            :value="item.id"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>

                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item prop="ind_type" label="行业类型">
                      <el-select
                          style="width: 100%"
                          size="small"
                          v-model="examForm.ind_type"
                          placeholder="请选择行业类型"
                      >
                        <el-option
                            v-for="item in ind_typeList"
                            :key="item.value"
                            :label="item.name"
                            :value="item.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="16">
                    <el-form-item prop="com_type" label="单位类型">
                      <el-select
                          style="width: 420px; margin-right: 20px"
                          size="small"
                          v-model="examForm.com_type"
                          placeholder="请选择单位类型"
                      >
                        <el-option
                            v-for="item in com_typeList"
                            :key="item.value"
                            :label="item.name"
                            :value="item.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>

                <!--              </div>-->
                <!--              <div>-->
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item prop="exam_city" label="考试形式">
                      <el-select
                          size="small"
                          style="width: 100%"
                          v-model="examForm.exam_city"
                          placeholder="请选择考试形式"
                      >
                        <el-option
                            v-for="item in examCityOptions"
                            :key="item.id"
                            :label="item.exam_city"
                            :value="item.exam_city"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="exam_date" label="考试时间">
                      <el-select
                          style="width: 100%"
                          size="small"
                          v-model="examForm.exam_date"
                          placeholder="请选择考试时间"
                      >
                        <el-option
                            v-for="item in examDateOptions"
                            :key="item.id"
                            :label="item.exam_date"
                            :value="item.exam_date"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <!--                                    <el-col :span="8">-->
                  <!--                                        <el-form-item prop="course" label="考试级别:">-->
                  <!--                                            <el-input v-model="examForm.course.id"></el-input>-->
                  <!--                                        </el-form-item>-->
                  <!--                                    </el-col>-->
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item :required="true" prop="email" label="电子邮箱">
                      <el-input
                          size="small"
                          v-model="examForm.email"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="16">
                    <el-form-item prop="work_duty" label="职务">
                      <el-select
                          style="width: 420px; margin-right: 20px"
                          size="small"
                          :disabled="true"
                          v-model="examForm.work_duty"
                          placeholder="请选择职务"
                      >
                        <el-option
                            v-for="item in work_dutyList"
                            :key="item.value"
                            :label="item.name"
                            :value="item.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="16">
                    <el-form-item prop="work_age" label-width="auto" label="从事薪酬管理（含薪税服务）工作年限（含实习经历）">
                      <el-input
                          :disabled="true"
                          size="small"
                          type="number"
                          v-model="examForm.work_age"
                          style="width:100px"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>
                <!--                <el-row :gutter="20">-->
                <!-- <el-col :span="1">
                  <el-form-item label="证件照:">
                    <img-upload
                      ref="imgUpload"
                      :url="examForm.photo"
                      @upload="upload"
                    ></img-upload>
                  </el-form-item>
                </el-col> -->
                <!--                </el-row>-->
                <!--                                <el-row>-->
                <!--                                    <el-col>-->
                <!--                                        <el-form-item label="电子签名:">-->
                <!--                                            <el-input v-model="examForm.sign"></el-input>-->
                <!--                                        </el-form-item>-->
                <!--                                    </el-col>-->
                <!--                                </el-row>-->
                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item :required="true" prop="phone" label="手机号码">
                      <el-input
                          size="small"
                          :disabled="true"
                          v-model="examForm.phone"
                      ></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item prop="code" label="短信验证码">
                      <div style="display: flex; align-items: center">
                        <el-input
                            size="small"
                            v-model="examForm.code"
                        ></el-input>
                        <el-button
                            :disabled="isDisabled"
                            size="mini"
                            style="margin-left: 10px; height: 32px"
                            @click="codeHandle"
                        >
                          <tencent-captcha
                              ref="captcha"
                              :phone="examForm.phone"
                              scene="2"
                          ></tencent-captcha>
                        </el-button>
                      </div>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row :gutter="20">
                  <el-col :span="8">
                    <el-form-item style="text-align: left;">
                      <el-checkbox v-model="examForm.is_train"
                      ><span style="font-size:14px;">您确认经培训达规定的参考学时数。</span></el-checkbox
                      >
                      <div
                          style="
                          display: flex;
                          align-items: center;
                          font-size: 10px;
                        "
                      >
                        <el-checkbox
                            style="margin-right: 10px;"
                            v-model="isRegister"
                        >
                          <!--                          <span-->
                          <!--                          style="font-size:12px;"-->
                          <!--                            >本人已阅读并同意<el-link-->
                          <!--                            style="font-size:12px;"-->
                          <!--                              type="warning"-->
                          <!--                              @click="isPrivacyFun"-->
                          <!--                              >《隐私政策》</el-link-->
                          <!--                            ><el-link style="font-size:12px;" type="warning" @click="isRegisterFun"-->
                          <!--                              >《用户注册协议》</el-link-->
                          <!--                            >，并承诺在申请国际薪税师报考时所提供的个人信息及材料均真实、合法、有效，否则将承担一切责任及后果（包括但不限于已取得证书的宣告作废）。-->
                          <!--                          </span>-->
                          <span style="font-size:14px;">本人承诺在申请 {{this.examForm.course.name}} 报考时所提供的个人信息及材料真实、合法、有效，否则将承担一切责任及后果（包括但不限于已取得证书的宣告作废）。</span>
                        </el-checkbox
                        >
                      </div>
                      <el-button size="small"  type="primary" style="margin-top: 12px" @click="examReg">提交</el-button>
                      <!--                                            <el-switch-->
                      <!--                                                    v-model="examForm.is_train"-->
                      <!--                                                    active-color="#13ce66">-->
                      <!--                                            </el-switch>-->
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
            </div>
          </el-form>
          <!-- <el-button
            size="small"
            v-if="active > 1 && active < 4"
            style="margin-top: 12px"
            @click="pre"
            >上一步</el-button
          >
          <el-button
            size="small"
            v-if="active < 3"
            style="margin-top: 12px"
            sabled
            @click="next"
            >下一步</el-button
          >
          <el-button
            size="small"
            v-if="active == 3"
            style="margin-top: 12px"
            @click="examReg"
            >提交</el-button
          > -->
        </el-card>

        <ExamAgreement @isExamAgreement="isExamAgreement" v-if="isExam_or_ExamAgreement_or_userKnow == 'ExamAgreement'"></ExamAgreement>


      </div>
    </div>
  </div>
</template>

<script>
import userKnow from '../../../components/userKnow/index'
import ExamAgreement from '../../../components/ExamAgreement/index'
// import PrivacyClause from '../../../components/PrivacyClause/index'
import RegistrationAgreement from '../../../components/RegistrationAgreement/index'
import registerForm from "../../../components/registerForm/registerForm";
import { regionData, CodeToText, TextToCode } from "element-china-area-data";
import {
  getProfile,
  exam_reg,
  getOrg,
  get_n_Org,
  editContent,
  courselist,
  examDateByCourseId,
  generateContract,
  viewContract,
  noticeList,
  signContract,
} from "../../../request/api";
import TencentCaptcha from "../../../components/TencentCaptcha/TencentCaptcha";
import {formatDate} from "../../../utils/formatDate";
// import imgUpload from "../../../components/imgUpload/imgUpload";
import "animate.css";
import "@/assets/icon/iconfont.css";
import {userType} from "../../../utils/base";

export default {
  name: "contentMain",
  filters:{
    hideMiddle(val) {
      if(val){
        return `${val.substring(0,3)}****${val.substring(val.length-3)}`
      }else{
        return ''
      }
    },
    // formatDate (time,courseId) {
    //   console.log(time,courseId)
    //   examDateByCourseId(courseId).then((res) => {
    //     console.log('具体考试城市 和 具体时间',res)
    //     let examDateOption = res.filter((item, index) => {
    //       return (
    //           res.findIndex((item1) => item1.exam_date == item.exam_date) == index
    //       );
    //     });
    //     this.examDateOptions = examDateOption;
    //     console.log(
    //         "this.this.examDateOptions",
    //         this.examDateOptions[0].exam_city
    //     );
    //   });
    //   // let date = new Date(time);
    //   // return formatDate(date, 'yyyy年MM月dd日 hh:mm')
    // },
    formatDate2 (time) {
      let date = new Date(time);
      return formatDate(date, 'yyyy-MM-dd')
    },
    expDate(time){
      let date = new Date(time);
      date.setFullYear(date.getFullYear() - 1);
      return formatDate(date, 'yyyy-MM-dd')
    }
  },
  data() {
    //根据不同证件类型不同表单验证
    var card_id_rule = (rule, value, callback) => {
      if (this.form.card_type == 1) {
        let reg =
            /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
        if (value === "") {
          callback(new Error("请填写身份证号码"));
        } else if (!reg.test(value)) {
          callback(new Error("身份证格式错误"));
        } else {
          callback();
        }
      } else if (this.form.card_type == 2) {
        let reg = /^[A-Z,a-z,\d]+$/;
        if (value === "") {
          callback(new Error("请填写护照"));
        } else if (!reg.test(value)) {
          callback(new Error("护照格式错误"));
        } else {
          callback();
        }
      } else if (this.form.card_type == 3) {
        let reg = /^[A-Z,a-z,\d]+$/;
        if (value === "") {
          callback(new Error("请填写港澳台胞证"));
        } else if (!reg.test(value)) {
          callback(new Error("证件格式错误"));
        } else {
          callback();
        }
      } else {
        callback();
      }
    };
    //手机号码表单验证
    var phoneRule = (rule, value, callback) => {
      let phoneRule = /^1[23456789]\d{9}$/;
      if (value === "") {
        callback(new Error("请输入手机号码"));
      } else if (!phoneRule.test(value)) {
        callback(new Error("手机号码格式错误"));
      } else {
        callback();
      }
    };
    //邮箱表单验证
    var email_rule = (rule, value, callback) => {
      let reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
      if (value === "") {
        callback(new Error("请填写电子邮箱"));
      } else if (!reg.test(value)) {
        callback(new Error("电子邮箱格式错误"));
      } else {
        callback();
      }
    };

    var work_duty_en_rule = (rule, value, callback) => {
      let reg = /^[A-Z,a-z]+$/;
      console.log("现有职务英文", value);
      if (value == null) {
        callback(new Error("请填写现有职务英文"));
      } else if (!reg.test(value)) {
        callback(new Error("格式错误"));
      } else {
        callback();
      }
    };
    var last_py_rule = (rule, value, callback) => {
      let reg = /^[A-Z,a-z]+$/;
      if (value === "") {
        callback(new Error("请填写姓拼音"));
      } else if (!reg.test(value)) {
        callback(new Error("格式错误"));
      } else {
        callback();
      }
    };
    var first_py_rule = (rule, value, callback) => {
      let reg = /^[A-Z,a-z]+$/;
      if (value === "") {
        callback(new Error("请填写名拼音"));
      } else if (!reg.test(value)) {
        callback(new Error("格式错误"));
      } else {
        callback();
      }
    };
    let _this = this;
    var province_rule = (rule, value, callback) => {
      console.log("工作区域验证函数", value);
      console.log(_this.examForm.province);
      if (this.examForm.province === "" || this.examForm.province == null) {
        callback(new Error("请选择工作区域"));
      } else {
        callback();
      }
    };
    var province_rule_update = (rule, value, callback) => {
      console.log("工作区域验证函数", value);
      console.log(_this.examForm.province);
      if (this.form.province === "" || this.form.province == null) {
        callback(new Error("请选择工作区域"));
      } else {
        callback();
      }
    };
    return {
      // ceshiForm:{},
      examTimeList : {},
      workMessageIsShow:false,
      hig_eduIsShow:false,
      personMessageIsShow:false,
      certDisplayOptions: [
        {id:1,name:'ACCA职业资格证书'},
        {id:2,name:'AICPA职业资格证书'},
        {id:3,name:'ATHE国际薪税师能力水平评价证书二级（中级）'},
        {id:4,name:'ATHE国际薪税师能力水平评价证书三级（初级）'},
        {id:5,name:'CIMA职业资格证书'},
        {id:6,name:'CMA职业资格证书'},
        {id:7,name:'IFA职业资格证书'},
        {id:8,name:'IFA国际薪税师能力水平评价证书二级（中级）'},
        {id:9,name:'IFA国际薪税师能力水平评价证书三级（初级）'},
        {id:10,name:'初级会计师职称证书'},
        {id:11,name:'初级经济师职称证书'},
        {id:12,name:'法律职业资格证书'},
        {id:13,name:'高级会计师职称证书'},
        {id:14,name:'高级经济师职称证书'},
        {id:15,name:'企业人力资源管理师职业技能（一级）证书'},
        {id:16,name:'企业人力资源管理师职业技能（二级）证书'},
        {id:17,name:'企业人力资源管理师职业技能（三级）证书'},
        {id:18,name:'企业人力资源管理师职业技能（四级）证书'},
        {id:19,name:'企业人力资源管理师职业资格（一级）证书'},
        {id:20,name:'企业人力资源管理师职业资格（二级）证书'},
        {id:21,name:'企业人力资源管理师职业资格（三级）证书'},
        {id:22,name:'企业人力资源管理师职业资格（四级）证书'},
        {id:23,name:'税务师职业资格证书'},
        {id:24,name:'薪酬管理职业技能（初级）证书'},
        {id:25,name:'薪酬管理职业技能（中级）证书'},
        {id:26,name:'薪酬管理职业技能（高级）证书'},
        {id:27,name:'薪税师职业技能（一级）证书'},
        {id:28,name:'薪税师职业技能（二级）证书'},
        {id:29,name:'薪税师职业技能（三级）证书'},
        {id:30,name:'薪税师职业技能（四级）证书'},
        {id:31,name:'中国商业联合会薪税师能力水平评价证书二级（中级）'},
        {id:32,name:'中国商业联合会薪税师能力水平评价证书三级（初级）'},
        {id:33,name:'中级会计师职称证书'},
        {id:34,name:'中级经济师职称证书'},
        {id:35,name:'注册会计师职业资格证书'},
        {id:0,name:'无'}
      ],
      //显示报考协议
      isExam_or_ExamAgreement_or_userKnow:'userKnow',
      model:'RegistrationAgreement',
      notiListDialogVisible:false,
      notice:{},
      noticeList: [],
      isRegister: false,
      isDisabled: false,
      Contract: null, //合同信息
      buttonDisabled: true,
      direction: "rtl", //编辑表单label方向
      drawer: false, //控制编辑表单的显示隐藏
      // active: 0, //报考表单默认步骤一
      toExamisShow: false, //控制报考表单的显示隐藏
      registerVisible: false, //控制添加报名表单显示隐藏
      profile: [], //档案数组
      person: {
        photo: "",
      }, //个人信息对象
      personCopy: {},
      courseList: [], //考试城市切换(薪酬管理师)
      state_map: {
        0: "机构一审驳回",
        1: "机构一审待审",
        2: "总部一审驳回",
        3: "总部一审待审",
        4: "机构二审驳回",
        5: "机构二审待审",
        6: "总部二审驳回",
        7: "总部二审待审",
        8: "全部审核通过",
      }, //审核状态字典
      rules: {
        province: [
          { required: true, validator: province_rule, trigger: "change" },
        ],
        name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        last_py: [{ required: true, validator: last_py_rule, trigger: "blur" }],
        first_py: [
          { required: true, validator: first_py_rule, trigger: "blur" },
        ],
        card_type: [
          { required: true, message: "请选择证件类型", trigger: "change" },
        ],
        cert:[
          { required: true, message: "请选择相关资质证书", trigger: "change" },
        ],
        card_id: [
          { required: true, message: "请输入证件号码", trigger: "blur" },
        ],
        birthday: [
          {
            required: true,
            message: "请输入出生年月",
            trigger: "blur",
          },
        ],
        ind_type: [
          { required: true, message: "请选择行业类型", trigger: "blur" },
        ],
        com_type: [
          { required: true, message: "请选择单位类型", trigger: "blur" },
        ],
        address: [
          {
            required: true,
            message: "请输入家庭住址",
            trigger: "blur",
          },
        ],
        org_code: [
          { required: true, message: "请输入报考机构代码", trigger: "blur" },
        ],
        school: [
          { required: true, message: "请输入学校名称", trigger: "blur" },
        ],
        grad_time: [
          { required: true, message: "请填写毕业年份", trigger: "change" },
        ],
        hig_edu: [
          { required: true, message: "请填写最高学历", trigger: "blur" },
        ],
        major: [{ required: true, message: "请输入专业门类", trigger: "blur" }],
        com_name: [
          { required: true, message: "请输入单位名称", trigger: "blur" },
        ],
        work_duty: [
          { required: true, message: "请输入现有职务", trigger: "blur" },
        ],
        work_duty_en: [
          { required: true, validator: work_duty_en_rule, trigger: "blur" },
        ],
        work_title: [
          { required: true, message: "请输入现有职称", trigger: "blur" },
        ],
        work_age: [
          { required: true, message: "请填写从业年限", trigger: "change" },
        ],
        course: [
          { required: true, message: "请输入考试级别", trigger: "blur" },
        ],
        exam_date: [
          { required: true, message: "请填写考试时间", trigger: "change" },
        ],
        exam_city: [
          { required: true, message: "请填写考试形式", trigger: "change" },
        ],
        is_train: [
          { required: true, message: "请选择是否参加培训", trigger: "change" },
        ],
        photo: [{ required: true, message: "请上传证件照", trigger: "blur" }],
        phone: [{ validator: phoneRule, trigger: "blur" }],
        code: [
          { required: true, message: "请输入手机验证码", trigger: "blur" },
        ],
      }, //报考表单验证
      formRules: {
        province: [
          {
            required: true,
            validator: province_rule_update,
            trigger: "change",
          },
        ],
        email: [{ required: true, validator: email_rule, trigger: "blur" }],
        name: [{ required: true, message: "请输入用户名", trigger: "blur" }],
        first_py: [
          { required: true, validator: first_py_rule, trigger: "blur" },
        ],
        last_py: [{ required: true, validator: last_py_rule, trigger: "blur" }],
        card_type: [
          { required: true, message: "请选择证件类型", trigger: "change" },
        ],
        card_id: [{ required: true, validator: card_id_rule, trigger: "blur" }],
        birthday: [
          {
            required: true,
            message: "请输入出生年月",
            trigger: "blur",
          },
        ],
        address: [
          {
            required: true,
            message: "请输入家庭住址",
            trigger: "blur",
          },
        ],
        org_code: [
          { required: true, message: "请输入机构代码", trigger: "blur" },
        ],
        school: [
          { required: true, message: "请输入学校名称", trigger: "blur" },
        ],
        grad_time: [
          { required: true, message: "请填写毕业年份", trigger: "change" },
        ],
        hig_edu: [
          { required: true, message: "请填写最高学历", trigger: "blur" },
        ],
        major: [{ required: true, message: "请输入专业门类", trigger: "blur" }],
        com_name: [
          { required: true, message: "请输入单位名称", trigger: "blur" },
        ],
        work_duty: [
          { required: true, message: "请选择现有职务", trigger: "blur" },
        ],
        ind_type: [
          { required: true, message: "请选择行业类型", trigger: "blur" },
        ],
        com_type: [
          { required: true, message: "请选择单位类型", trigger: "blur" },
        ],
        city: [
          { required: true, message: "请填写工作区域", trigger: "change" },
        ],
        work_duty_en: [
          { required: true, message: "请输入现有职务英文", trigger: "blur" },
        ],
        work_title: [
          { required: true, message: "请输入现有职称", trigger: "blur" },
        ],
        work_age: [
          { required: true, message: "请填写从业年限", trigger: "change" },
        ],
        course: [
          { required: true, message: "请输入考试级别", trigger: "blur" },
        ],
        exam_date: [
          { required: true, message: "请填写考试时间", trigger: "change" },
        ],
        exam_city: [
          { required: true, message: "请填写考试形式", trigger: "change" },
        ],
        is_train: [
          { required: true, message: "请选择是否参加培训", trigger: "change" },
        ],
        photo: [{ required: true, message: "请上传证件照", trigger: "blur" }],
        phone: [{ validator: phoneRule, trigger: "blur" }],
        code: [
          { required: true, message: "请输入手机验证码", trigger: "blur" },
        ],
      }, //编辑表单验证
      examForm: {
        name: "", //姓名
        last_py: "", //姓拼音
        first_py: "", //名拼音
        card_type: 1, //证件类型
        card_id: "", //证件号码
        birthday: "", //出生日期
        address: "", //家庭住址
        province: "", //省份
        city: "", //城市
        dis: "", //区/县
        org: {
          org_code: "", //机构代码
        },
        exam_org_code: "",
        school: "", //毕业学校
        grad_time: "", //毕业时间
        hig_edu: "", //最高学历
        major: "", //专业门类
        com_name: "", //单位名称
        work_duty: "", //现有职务
        work_duty_en: "", //现有职务英文
        work_title: "", //现有职称
        work_age: "0", //从业年限
        course: {
          id: "", //考试级别,
          name: "",
        },
        exam_date: "", //考试时间
        exam_city: "", //考试城市 (薪酬管理师)
        is_train: false, //是否参加培训 (薪酬管理师)
        photo: "", //上传证件照片
        sign: "", //电子签名
        phone: "", //手机号码
        code: "", //手机验证码
        ind_type: null,
        com_type: null,
      }, //报考表单字段
      cardOptions: [
        { id: 1, name: "居民身份证" },
        { id: 2, name: "护照" },
        { id: 3, name: "港澳台胞身份证" },
      ], //证件类型字典
      examCityOptions: [], //考试城市
      examDateOptions: [], //考试时间
      form: {
        exam_org_code: "",
        ind_type: "",
        com_type: "",
        province: "",
        work_duty:"",
        course:{
          course_name:''
        },
        org:{
          org_name:""
        }
      }, //编辑表单
      areaOptions: regionData, //省市区三级联动
      selectedOptions: [], //选择后的省市区对象数组
      selectedOptionsUpdate: [], //修改的 省市区
      isReject: {
        0: "org_1_reject",
        1: "org_1_wait",
        2: "admin_1_reject",
        3: "admin_1_wait",
        4: "org_2_reject",
        5: "org_2_wait",
        6: "admin_2_reject",
        7: "admin_2_wait",
        8: "allpass",
      },
      work_dutyList: [
        {
          name: "单位负责人/高级管理人员（董事长/总裁/副总裁等）",
          value:
              "单位负责人/高级管理人员（董事长/总裁/副总裁等）#Person in charge / Senior Management (Chairman / President / Vice President, etc.)",
        },
        {
          name: "事务所负责人/高级管理人员（董事长/权益合伙人/授薪合伙人等）",
          value:
              "事务所负责人/高级管理人员（董事长/权益合伙人/授薪合伙人等）#Head of the firm / Senior Management (Chairman / Equity Partners / Salaried Partners, etc.)",
        },
        {
          name: "人力资源部（薪酬总监岗及以上/薪税服务总监岗及以上）",
          value:
              "人力资源部（薪酬总监岗及以上/薪税服务总监岗及以上）#Human Resources Dept. (Payments Director Post and above/Payments and Tax Service Director Post and above)",
        },
        {
          name: "财务部（总监岗及以上）",
          value:
              "财务部（总监岗及以上）#Finance Dept. (Director Post and above)",
        },
        {
          name: "客服部/市场部（总监岗及以上）",
          value:
              "客服部/市场部（总监岗及以上）#Customer Service Dept. / Marketing Dept. (Director Post and above)",
        },
        {
          name: "业务部（总监岗及以上）",
          value:
              "业务部（总监岗及以上）#Business Dept. (Director Post and above)",
        },
        {
          name: "其他未列明部门（总监岗及以上）",
          value:
              "其他未列明部门（总监岗及以上）#Other Unspecified Departments (Director Post and above)",
        },
        {
          name: "人力资源部（薪酬经理岗/薪税服务经理岗）",
          value:
              "人力资源部（薪酬经理岗/薪税服务经理岗）#Human Resources Dept. (Payments Manager Post/Payments and Tax Service Manager Post)",
        },
        {
          name: "财务部（经理岗）",
          value:
              "财务部（经理岗）#Finance Dept. (Manager Post)",
        },
        {
          name: "客服部/市场部（经理岗）",
          value:
              "客服部/市场部（经理岗）#Customer Service Dept. / Marketing Dept.  (Manager Post)",
        },
        {
          name: "业务部（经理岗）",
          value:
              "业务部（经理岗）#Business Dept. (Manager Post)",
        },
        {
          name: "其他未列明部门（经理岗）",
          value:
              "其他未列明部门（经理岗）#Other Unspecified Departments (Manager Post)",
        },
        {
          name: "人力资源部（薪酬专员岗/薪税服务专员岗）",
          value:
              "人力资源部（薪酬专员岗/薪税服务专员岗）#Human Resources Dept. (Payments Specialist Post/Payments and Tax Service Specialist Post)",
        },
        {
          name: "财务部（专员岗）",
          value:
              "财务部（专员岗）#Finance Dept. (Specialist Post)",
        },
        {
          name: "客服部/市场部（专员岗",
          value:
              "客服部/市场部（专员岗）#Customer Service Dept. / Marketing Dept.  (Specialist Post)",
        },
        {
          name: "业务部（专员岗）",
          value:
              "业务部（专员岗）#Business Dept. (Specialist Post)",
        },
        {
          name: "其他未列明部门（专员岗）",
          value:
              "其他未列明部门（专员岗）#Other Unspecified Departments (Specialist Post)",
        },
        {
          name: "其他人员（在校学生-人力资源管理、工商管理、行政管理专业）",
          value:
              " 其他人员（在校学生-人力资源管理、工商管理、行政管理专业）#Others (Student-Major in HR Management, Business Administration, Administration）",
        },
        {
          name: "其他人员（在校学生-会计、税务、财务管理专业）",
          value:
              "其他人员（在校学生-会计、税务、财务管理专业）#Others (Student-Major in Accounting, Taxation, Financial management）",
        },
        {
          name: "其他人员（在校学生-其他专业）",
          value:
              "其他人员（在校学生-其他专业）#Others (Student-other majors）",
        },
        {
          name: "自由职业者",
          value:
              "自由职业者#Freelancers",
        }
      ],
      ind_typeList: [
        {value:1,name:'人力资源与人力资本服务'},
        {value:2,name:'集成电路'},
        {value:3,name:'人工智能'},
        {value:4,name:'软件与平台'},
        {value:5,name:'生命科学'},
        {value:6,name:'生物医药'},
        {value:7,name:'医疗保健'},
        {value:8,name:'航空与航天'},
        {value:9,name:'汽车'},
        {value:10,name:'化工'},
        {value:11,name:'工业产品和服务'},
        {value:12,name:'消费品'},
        {value:13,name:'能源和自然资源'},
        {value:14,name:'金融'},
        {value:15,name:'基础建设和建筑产品'},
        {value:16,name:'机械和设备'},
        {value:17,name:'媒体'},
        {value:18,name:'金属和矿业'},
        {value:19,name:'私募基金'},
        {value:20,name:'零售'},
        {value:21,name:'高科技'},
        {value:22,name:'电信'},
        {value:23,name:'公用事业'},
        {value:24,name:'教育'},
        {value:25,name:'文化'},
        {value:26,name:'其他'},
        {value:27,name:'无'}
      ],
      com_typeList: [
        { name: "事业单位", value: 1 },
        { name: "人力资源服务机构", value: 2 },
        { name: "会计（税务,律师）事务所", value: 3 },
        { name: "其他中介机构", value: 4 },
        { name: "金融机构（银行,证券,保险,信托,基金等）", value: 5 },
        { name: "院校", value: 6 },
        { name: "其他", value: 7 },
      ],
    };
  },
  methods: {
    showExamAgreement(params){
      console.log(params)
      this.isExam_or_ExamAgreement_or_userKnow = params;
    },
    //判断是否为 用户
    isUser(){
      let token = this.$cookies.get("token")
      if(token){
        // const loading = this.$loading({
        //   lock: true,
        //   text: 'Loading',
        //   spinner: 'el-icon-loading',
        //   background: 'rgba(255, 255, 255, 0.7)'
        // });
        // setTimeout(() => {
        //   loading.close();
        // }, 2000);
        let { user_type } = userType(token);
        if(user_type == 1){

        }else if(user_type == 2){
          this.$router.push('/org/index');
        }else if(user_type == 3){
          this.$router.push('/admin/index');
        }
      }
    },
    isExamAgreement(params){
      this.isExam_or_ExamAgreement_or_userKnow = params;
    },
    toRegister(params){
      this.model = params
    },
    showNoti(title){
      console.log('公告标题',title);
      this.notiListDialogVisible = true;
      for (let item of this.noticeList){
        if(item.title == title){
          this.notice = item
        }
      }
    },
    //获取公告集合
    getNoticeList() {
      noticeList().then((res) => {
        this.noticeList = res;
        console.log("公告集合", res);
      });
    },
    isRegisterFun() {
      window.open("/exam_register.html");
    },
    isPrivacyFun() {
      window.open("/exam_privacy.html");
    },
    //合同签署
    toTransation(params) {
      this.getExamDate(params.course.id);
      this.$confirm(params.signed ? '是否重签签署报考确认书':'是否继续签署报考确认书', "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
          .then(() => {
            console.log('this.examDateOptions',this.examDateOptions)
            let province = params.province == null ? "" : params.province;
            let city = params.city == null ? "" : params.city;
            let dis = params.dis == null ? "" : params.dis;
            let detailTime = this.examDateOptions.filter((item) => item.exam_date = params.exam_date)
            console.log(province,city,dis,params.card_id,params.org.org_name,params.exam_org.org_name,detailTime)
            let TransationObj = {
              openid: params.card_id,
              pid:params.id,
              parameter_map: {
                major:params.major,
                org:params.org.org_name,
                exam_org: params.exam_org.org_name,
                course: params.course.name,
                ispass:(params.exam_list && params.exam_list.is_pass == false) || params.make_up_count > 0 ? '是':'否',
                name_en:params.first_py + ' / ' + params.last_py,
                time_detail: detailTime[0].time_detail,
                exam_city: params.exam_city,
                user_name:params.name,
                card_type: params.card_type_display,
                card_id: params.card_id,
                gender: params.gender_display,
                birthday: params.birthday,
                hig_edu: params.hig_edu,
                grad_time:params.grad_time ? params.grad_time.split('-')[0]+'年'+params.grad_time.split('-')[1]+'月':'',
                cert: this.certDisplayOptions.filter(
                    (element) => element.id == params.cert
                )[0].name,
                region: province + " " + city + " " + dis,
                work_age: params.work_age + "年",
                com_name: params.com_name,
                email: params.email,
                work_duty_cn:params.work_duty.split('#')[0],
                work_duty_en:params.work_duty.split('#')[1],
                sign: "",
                current_date:
                    new Date().getFullYear() +
                    "年" +
                    (new Date().getMonth() + 1) +
                    "月" +
                    new Date().getDate() +
                    "日",
                ind_type: this.ind_typeList.filter(
                    (element) => element.value == params.ind_type
                )[0].name,
                com_type: this.com_typeList.filter(
                    (element) => element.value == params.com_type
                )[0].name,
                phone: params.phone
              },
            };
            console.log(TransationObj);
            generateContract(TransationObj).then((res) => {
              console.log(res);
              params.contract_id = res.contract_id;
              let paramsObj = {
                pid: params.id,
                contract_id: params.contract_id,
              };
              signContract(paramsObj).then((res) => {
                console.log(res);
              });
              window.open(res.sign_url);
            });
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消",
            });
          });
    },
    //查看合同
    lookTransation(contract_id) {
      viewContract({ contract_id: contract_id }).then((res) => {
        window.open(res.view_url);
      });
    },
    //获取档案
    getProfile() {
      this.isUser();
      getProfile().then(async (res) => {
        console.log("档案信息", res);
        for (let item of res){
          console.log('科目id',item.course.id)
          await examDateByCourseId(Number(item.course.id)).then((res) => {
            this.examTimeList[item.course.id] = res
          })
        }
        console.log('examTimeList',this.examTimeList)
        let resCopy = JSON.parse(JSON.stringify(res));
        this.profile = resCopy;
        let newRes = this.ReverseRankingDate(res, "update_time");
        // let newRes = res;
        console.log("res---", newRes);
        // for (let item of newRes) {
        //     item['photo'] = item['photo'] + '?' + Math.round(Math.random() * 100000);
        //     // if (item.state_code > 7) {
        //     //     this.person = item;
        //     //     this.person['photo'] = item['photo'] + '?' + Math.round(Math.random() * 100000);
        //     //     return
        //     // }
        // }

        //bug-----------
        this.personCopy = JSON.parse(JSON.stringify(newRes.shift()));
        for (let item of newRes) {
          for (let key in item) {
            if (item[key] !== null && item[key] !== "") {
              this.personCopy[key] = item[key];
            }
          }
        }

        // let new_person = newRes[newRes.length - 1];
        // let photoFlag = this.personCopy['photo']
        // for (let item in this.personCopy){
        //     if(this.personCopy[item] == null || this.personCopy[item] != new_person[item] && new_person[item] != null){
        //         this.personCopy[item] = new_person[item];
        //     }
        // }
        // if(this.personCopy['photo'].includes('null')){
        //     this.personCopy['photo'] = photoFlag;
        //     console.log('比较图片',this.personCopy['photo'])
        // }
        console.log("比较用户信息", this.personCopy);
        this.person = this.personCopy;
        console.log("photo", newRes[newRes.length - 1]);
        console.log("this.person", this.person);
      });
    },
    //获取考试城市列表(薪酬管理师)
    CourseList() {
      courselist().then((res) => {
        let arr = [];
        for (let item of res) {
          for (let item2 of item.examdate) {
            arr.push(item2["exam_city"]);
          }
        }
        this.courseList = arr;
        console.log("this.courseList", this.courseList);
      });
    },
    //N次报名
    addOrg(params) {
      console.log("params", params);
      get_n_Org(params)
          .then((res) => {
            console.log(res);
            this.registerVisible = false;
            this.getProfile();
          })
          .catch((err) => {
            this.$refs.registerForm.flag = false;
            this.$message({
              type: "error",
              message: err.msg + ',' + err.errors,
            });
          });
    },
    //添加报名表单隐藏
    addRegisterClose(done) {
      done();
    },
    //去报考
    toExam(profile_id) {
      // this.active = 1;
      this.toExamisShow = true;
      console.log(this.$refs.imgUpload);
      let _this = this;
      console.log("profile_id", profile_id);
      for (let item of this.profile) {
        if (item.id === profile_id) {
          this.examForm.id = item.id;
          this.examForm.major = item.major;
          this.examForm.grad_time = item.grad_time;
          this.examForm.hig_edu = item.hig_edu;
          this.examForm.last_py = item.last_py;
          this.examForm.first_py = item.first_py;
          this.examForm.com_name = item.com_name;
          this.examForm.course.id = item.course.id;
          this.examForm.course.name = item.course.name;
          this.examForm.card_type = item.card_type;
          this.examForm.card_id = item.card_id;
          this.examForm.birthday = item.birthday;
          this.examForm.name = item.name;
          this.examForm.address = item.address;
          this.examForm.org.org_code = item.org.org_code;
          this.examForm.org.org_name = item.org.org_name;
          this.examForm.phone = item.phone;
          this.examForm.work_duty = item.work_duty;
          this.examForm.work_duty_en = item.work_duty_en;
          this.examForm.work_age = item.work_age;
          this.examForm.province = item.province;
          this.examForm.exam_list = item.exam_list[item.exam_list.length - 1] ? item.exam_list[item.exam_list.length - 1] :null;
          this.examForm.city = item.city;
          this.examForm.dis = item.dis;
          this.examForm.cert = item.cert;
          this.examForm.gender = item.gender;
          this.examForm.card_type_display = item.card_type_display;
          this.examForm.gender_display = item.gender_display;
          this.examForm.exam_city = item.exam_city;
          this.examForm.email = item.email;
          this.examForm.ind_type = item.ind_type;
          this.examForm.com_type = item.com_type;
          this.examForm.make_up_count = item.make_up_count;
          _this.getExamDate(this.examForm.course.id);
          try {
            if (this.examForm.province == this.examForm.city) {
              console.log(
                  this.examForm.province,
                  this.examForm.city,
                  this.examForm.dis
              );
              this.selectedOptions.push(
                  TextToCode[this.examForm.province].code,
                  TextToCode[this.examForm.province]["市辖区"].code,
                  TextToCode[this.examForm.province]["市辖区"][this.examForm.dis]
                      .code
              );
            } else {
              console.log(
                  this.examForm.province,
                  this.examForm.city,
                  this.examForm.dis
              );
              this.selectedOptions.push(
                  TextToCode[this.examForm.province].code,
                  TextToCode[this.examForm.province][this.examForm.city].code,
                  TextToCode[this.examForm.province][this.examForm.city][
                      this.examForm.dis
                      ].code
              );
            }
          } catch (error) {
            this.examForm.province = null;
            this.examForm.city = null;
            this.examForm.dis = null;
          }
          if (this.examForm.course.name.includes("薪酬管理")) {
            this.examForm.is_train = false;
          } else {
            this.examForm.is_train = false;
          }
        }
      }
      console.log("this.examForm", this.examForm);
    },
    //报考返回主页
    goBack() {
      console.log("返回");
      this.toExamisShow = false;
      this.getProfile();
    },
    //步骤上一步
    // pre() {
    //   if (this.active-- < 2) this.active = 1;
    // },
    //步骤下一步
    // next() {
    //   // console.log(this.examForm.photo.includes("http"));
    //   if (this.examForm.photo.includes("http")) {
    //     this.$refs.imgUpload.base();
    //   }
    //   if (this.active == 1) {
    //     this.Somevalid([
    //       "first_py",
    //       "last_py",
    //       "school",
    //       "address",
    //       "grad_time",
    //       "hig_edu",
    //       "major",
    //     ]);
    //   } else if (this.active == 2) {
    //     this.Somevalid([
    //       "com_name",
    //       "work_duty",
    //       "work_duty_en",
    //       "work_title",
    //       "work_age",
    //     ]);
    //   }
    // },
    //部分表单验证
    // Somevalid(validList) {
    //   this.$nextTick(() => {
    //     let validArr = [];
    //     this.$refs["examForm"].validateField(validList, (valid) => {
    //       validArr.push(valid);
    //     });
    //     if (validArr.every((item) => item === "")) {
    //       if (this.active++ > 3) this.active = 1;
    //     }
    //   });aiio
    // },
    //报考表单提交
    examReg() {
      this.$refs["examForm"].validate((valid) => {
        console.log(
            "this.examForm.course.id",
            this.examForm.course.id !== 4 ||
            this.examForm.course.id !== 5 ||
            this.examForm.course.id !== 6,
            this.examForm.is_train
        );
        if (valid) {
          if (this.examForm.exam_org_code !== "") {
            console.log(this.examForm.exam_org_code);
            let orgCode = this.examForm.exam_org_code;
            getOrg(orgCode)
                .then((res) => {
                  console.log(res.course[0].name.includes('薪税'))
                  if(res.course && res.course[0].name.includes('薪税')){
                    if (this.examForm.is_train) {
                      if (this.isRegister) {
                        console.log('this.examDateOptions',this.examDateOptions)
                        this.$confirm(`<div style="color: darkslategray"><p>请确认以下信息是否正确：</p><p>*姓：${this.examForm.last_py}</p><p>*名：${this.examForm.first_py}</p></div>`, '信息确认', {
                          confirmButtonText: '确定',
                          cancelButtonText: '取消',
                          dangerouslyUseHTMLString: true,
                        }).then(() => {
                          this.examForm["course_id"] = this.examForm.course.id;
                          this.examForm["org_code"] = this.examForm.exam_org_code;
                          this.examForm["exam_code"] = this.examForm.org.org_code;
                          console.log(this.examForm, "通过");
                          console.log(res);
                          let province =
                              this.examForm.province == null
                                  ? ""
                                  : this.examForm.province;
                          let city =
                              this.examForm.city == null ? "" : this.examForm.city;
                          let dis =
                              this.examForm.dis == null ? "" : this.examForm.dis;
                          let detailTime = this.examDateOptions.filter((item) => item.exam_date = this.examForm.exam_date)
                          let params = {
                            openid: this.examForm.card_id,
                            pid:this.examForm.id,
                            parameter_map: {
                              major:this.examForm.major,
                              org:this.examForm.org.org_name,
                              exam_org: res.org_name,
                              course: this.examForm.course.name,
                              ispass:(this.examForm.exam_list && this.examForm.exam_list.is_pass == false) || this.examForm.make_up_count > 0 ? '是':'否',
                              time_detail: detailTime[0].time_detail,
                              exam_city: this.examForm.exam_city,
                              user_name: this.examForm.name,
                              name_en:this.examForm.first_py + ' / ' + this.examForm.last_py,
                              card_type: this.examForm.card_type_display,
                              card_id: this.examForm.card_id,
                              gender: this.examForm.gender_display,
                              birthday: this.examForm.birthday,
                              hig_edu: this.examForm.hig_edu,
                              grad_time:this.examForm.grad_time ? this.examForm.grad_time.split('-')[0]+'年'+this.examForm.grad_time.split('-')[1]+'月':'',
                              cert: this.certDisplayOptions.filter(
                                  (element) => element.id == this.examForm.cert
                              )[0].name,
                              region: province + " " + city + " " + dis,
                              work_age: this.examForm.work_age + "年",
                              com_name: this.examForm.com_name,
                              email: this.examForm.email,
                              work_duty_cn: this.examForm.work_duty.split('#')[0],
                              work_duty_en:this.examForm.work_duty.split('#')[1],
                              sign: "",
                              current_date:
                                  new Date().getFullYear() +
                                  "年" +
                                  (new Date().getMonth() + 1) +
                                  "月" +
                                  new Date().getDate() +
                                  "日",
                              ind_type: this.ind_typeList.filter(
                                  (element) => element.value == this.examForm.ind_type
                              )[0].name,
                              com_type: this.com_typeList.filter(
                                  (element) => element.value == this.examForm.com_type
                              )[0].name,
                              phone: this.examForm.phone
                            },
                          };
                          console.log(params.parameter_map);
                          exam_reg(this.examForm)
                              .then((res) => {
                                let ContractUrl = "";
                                generateContract(params).then((res) => {
                                  console.log("合同填充返回数据", res);
                                  ContractUrl = res.sign_url;
                                  this.examForm.contract_id = res.contract_id;
                                  let paramsObj = {
                                    pid: this.examForm.id,
                                    contract_id: this.examForm.contract_id,
                                  };
                                  signContract(paramsObj).then((res) => {
                                    console.log(res);
                                  });
                                  this.toExamisShow = false;
                                  this.getProfile();
                                  window.open(ContractUrl);
                                });
                                console.log(res);
                                this.$message({
                                  type: "success",
                                  message: "提交成功",
                                });
                              })
                              .catch((err) => {
                                this.$refs["captcha"].isShow = true;
                                console.log("catch", err);
                                this.$message({
                                  type: "error",
                                  message: err.msg,
                                });
                              });

                        }).catch((err) => {
                          this.$message({
                            type: 'info',
                            message: '已取消'+err
                          });
                        });
                      } else {
                        this.$message({
                          type: "warning",
                          message: "请您确定所提供的的个人信息及材料真实、合法、有效。",
                        });
                      }
                    } else {
                      this.$message({
                        type: "warning",
                        message: "您确认经培训已达规定的参考学时数。",
                      });
                    }
                  }else{
                    this.$message({ type: "error", message: "对不起！该机构权限不可报考该科目" });
                  }
                })
                .catch((err) => {
                  console.log(err);
                  this.$message({ type: "error", message: "报考机构不存在" });
                });
          } else {
            this.$message({
              type: "warning",
              message: "机构代码不能为空",
            });
          }
        } else {
          this.$message({
            type: "warning",
            message: "请检查是否漏写字段",
          });
          console.log("error submit!!");
          return false;
        }
      });
    },
    //上传组件内容回调赋值给报考表单photo字段(报考)
    upload(photo) {
      this.examForm.photo = photo;
      console.log(photo);
    },
    //上传组件内容回调赋值给报考表单photo字段(编辑)
    updateUpload(photo) {
      console.log("编辑后的证件照", photo);
      this.form.photo = photo;
    },
    //获取考试城市与考试时间(根据课程id)
    getExamDate(course_id) {
      examDateByCourseId(course_id).then((res) => {
        console.log('具体考试城市 和 具体时间',res)
        let examCityOption = res.filter((item, index) => {
          return (
              res.findIndex((item1) => item1.exam_city == item.exam_city) == index
          );
        });
        let examDateOption = res.filter((item, index) => {
          return (
              res.findIndex((item1) => item1.exam_date == item.exam_date) == index
          );
        });
        this.examDateOptions = examDateOption;
        console.log(
            "this.this.examDateOptions",
            this.examDateOptions[0].exam_city
        );
        this.examCityOptions = examCityOption;
        this.examForm.exam_city = this.examDateOptions[0].exam_city;
        this.examForm.exam_date = this.examDateOptions[0].exam_date;
      });
    },
    //打开编辑表单并赋值
    updateExam(exam_id) {
      this.drawer = true;
      console.log(exam_id);
      console.log("编辑表单内部档案", this.profile);
      for (let item of this.profile) {
        if (item.id == exam_id) {
          this.form = JSON.parse(JSON.stringify(item));
          // this.$set(this.ceshiForm,'data',JSON.parse(JSON.stringify(item)))
          // console.log('测试数据赋值',this.ceshiForm);
          console.log("编辑档案item", item);
          console.log(this.form.province, this.form.city, this.form.dis);
          if (this.form.province == this.form.city) {
            try {
              this.selectedOptionsUpdate.push(
                  TextToCode[this.form.province].code,
                  TextToCode[this.form.province]["市辖区"].code,
                  TextToCode[this.form.province]["市辖区"][this.form.dis].code
              );
            } catch (error) {
              console.log(error);
              this.form.province = "";
              this.form.city = "";
              this.form.dis = "";
            }
          } else {
            try {
              this.selectedOptionsUpdate.push(
                  TextToCode[this.form.province].code,
                  TextToCode[this.form.province][this.form.city].code,
                  TextToCode[this.form.province][this.form.city][this.form.dis]
                      .code
              );
            } catch (error) {
              console.log(error);
              this.form.province = "";
              this.form.city = "";
              this.form.dis = "";
            }
          }
          this.oldForm = JSON.parse(JSON.stringify(this.form));
          this.getExamDate(this.form.course.id);
        }
      }
      console.log("exam_id", exam_id);
    },
    //编辑表单的关闭
    ExamhandleClose(done) {
      console.log("修改关闭");
      this.getProfile();
      done();
    },
    //获取省市区
    addressChange(arr) {
      this.form.province = CodeToText[arr[0]];
      this.form.city = CodeToText[arr[1]];
      this.form.dis = CodeToText[arr[2]];
    },

    addressChangeExam(arr) {
      this.examForm.province = CodeToText[arr[0]];
      this.examForm.city = CodeToText[arr[1]];
      this.examForm.dis = CodeToText[arr[2]];
    },
    //修改信息
    editContent() {
      this.$refs["updateForm"].validate((valid) => {
        if (valid) {
          console.log("oldForm", this.oldForm, "newForm", this.form);
          let params = { pid: this.form.id };
          for (let item in this.oldForm) {
            if (this.form[item] !== this.oldForm[item]) {
              if (
                  Object.prototype.toString.call(this.form[item]) ===
                  "[object Object]"
              ) {
                continue;
              }
              params[item] = this.form[item];
            }
          }
          let cardObj = {
            card_id: this.form.card_id,
            card_type: this.form.card_type,
            name: this.form.name,
          };
          for (let key in params) {
            if (cardObj.hasOwnProperty(key)) {
              Object.assign(params, cardObj);
            }
          }
          console.log("params", params);
          editContent(params)
              .then((res) => {
                this.getProfile();
                console.log(res);
                this.$message({
                  type: "success",
                  message: "修改成功",
                });
                this.drawer = false;
              })
              .catch((err) => {
                let resetForm = JSON.parse(JSON.stringify(this.oldForm));
                this.form = resetForm;
                this.person = this.oldForm;
                this.$message({
                  type: "error",
                  message: err.msg,
                });
              });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    //取消修改
    editHandleClose() {
      this.drawer = false;
      this.getProfile();
    },
    ReverseRankingDate(data, p) {
      for (let i = 0; i < data.length - 1; i++) {
        for (let j = 0; j < data.length - 1 - i; j++) {
          // console.log(Date.parse(data[j][p]));
          if (Date.parse(data[j][p]) > Date.parse(data[j + 1][p])) {
            var temp = data[j];
            data[j] = data[j + 1];
            data[j + 1] = temp;
          }
        }
      }
      return data;
    },
    codeHandle() {
      if (this.$refs.isShow) {
        this.$refs.captcha.handleCode();
        this.isDisabled = true;
      }
    },
  },
  watch: {
    // active(){
    //     if(this.active == 1){
    //         this.$nextTick(() =>{
    //             this.$refs['examForm'].validateField(['school'],(valid) =>{
    //                 console.log(valid == '')
    //             })
    //         })
    //     }
    // }
  },
  computed: {
    //用户部分字段禁用
    userDisable() {
      if (this.form.state_code && this.oldForm.card_type == 1) {
        return true;
      }
      return false;
    },
    // detailTime(){
    //   return (item,course_id,exam_date) =>{
    //     console.log('时间参数',item,course_id,exam_date);
    //     let detailTime = '';
    //     for (let item of item.org.course){
    //       if(item.id == course_id){
    //         for (let item2 of item.examdate){
    //           if(item2.exam_date == exam_date){
    //             detailTime = item2.time_detail;
    //             console.log('具体时间',item2.time_detail)
    //           }
    //         }
    //       }
    //     }
    //     return detailTime
    //   }
    // }
    //设置头像
    // squareUrl() {
    //     if (!this.person.photo.includes('null')) {
    //         return this.person.photo;
    //     }
    //     return "https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png";
    // },
  },
  components: {
    //报名组件
    registerForm,
    //上传证件照组件
    // imgUpload,
    //腾讯验证码组件
    TencentCaptcha,
    //报名注册协议组件
    RegistrationAgreement,
    //报名隐私政策组件
    // PrivacyClause,
    //报考阶段协议组件
    ExamAgreement,
    //用户须知
    userKnow
  },
  created() {
    this.getProfile();
    this.CourseList();
    this.getNoticeList();
  },
};
</script>

<style>
.add-reigster .el-dialog__body{
  padding: 0px;
}
.updateButton .el-form-item__content {
  margin-left: 0px !important;
}
.main-bottom .el-row {
  height: 100%;
}

.el-scrollbar__wrap {
  /*overflow: hidden;*/
  overflow-y: scroll;
}
.xuzhiClass{
  min-width: 1200px;
}
.xuzhiClass .el-message-box__message{
  padding-left: 0px;
}
.xuzhiClass .el-message-box__content{
  padding: 0px;
}
</style>

<style scoped>
.inputWidth {
  width: 160px;
}
.exam-header {
  margin-top: 10px;
}

.icon-xingbienan {
  color: #409eff;
  font-size: 20px;
}

.icon-xingbienan-copy {
  font-size: 20px;
  color: #e89abe;
}

.examModel {
  margin-bottom: 20px;
  background-color: rgb(240, 249, 235);
}

.exam {
  height: 100%;
}

.exam .left {
  text-align: left;
}

.exam .right {
  text-align: left;
}

.exam .right .title {
  font-size: 15px;
  font-weight: 600;
  color: #8c939d;
  line-height: 17px;
}

.exam .right .content {
  margin-left: 40px;
  margin-top: 10px;
  font-size: 15px;
  color: #8c939d;
  line-height: 25px;
}

.exam .left .content {
  margin-left: 20px;
  margin-top: 10px;
  font-size: 15px;
  color: #8c939d;
  line-height: 25px;
}

.exam .left .title {
  font-size: 15px;
  font-weight: 600;
  color: #000000;
  line-height: 17px;
}

.exam .left .title .head {
  font-size: 17px;
  font-weight: 600;
  color: #000000;
}

.athor {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  margin-top: 20px;
}

.athor-left {
  height: 100%;
}

.athor-right {
  height: 100%;
  margin-top: 20px;
}

.school-content .title {
  font-size: 17px;
  font-weight: 600;
  width: 100%;
  text-align: left;
}

.school-content .content {
  margin-top: 10px;
  font-size: 14px;
  width: 100%;
  text-align: left;
  line-height: 30px;
}

.school-content .content .end {
  margin-left: 10px;
}

.work-content .title {
  font-size: 17px;
  font-weight: 600;
  width: 100%;
  text-align: left;
}

.work-content .content {
  margin-top: 10px;
  font-size: 14px;
  width: 100%;
  text-align: left;
  line-height: 30px;
}

.work-content .content .end {
  margin-left: 10px;
}

.userModel {
  background-color: rgb(236, 245, 255);
}

.informModel {
  background-color: rgb(242, 246, 252);
  min-height: 260px;
}

.flowModel {
  background-color: rgb(242, 246, 252);
}

.content-main {
  width: 1200px;
  height: 100%;
  margin: 0 auto;
  background-color: white;
  color: white;
}

.register-content {
  padding: 10px;
}

.user-img {
  width: 30%;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.user {
  font-size: 14px;
  width: 72%;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.user > div {
  display: flex;
  align-items: center;
}

.user > .user-name > .name {
  font-size: 19px;
  font-weight: 600;
  color: #000000;
}

.user-describe {
  font-size: 14px;
  text-align: left;
}

.user-describe div {
  margin: 10px 0px;
}

.inform {
  display: flex;
  justify-content: space-between;
}

.inform > span {
  font-size: 17px;
  font-weight: 700;
  color: #e1305a;
}

.flow {
  display: flex;
  justify-content: space-between;
}

.flow > span {
  font-size: 17px;
  font-weight: 700;
  color: #8d4b8b;
}

.flow-describe {
  word-wrap: break-word;
  text-align: left;
}

.flow-describe > p {
  text-align: left;
  font-size: 14px;
}

.main-top {
  width: 100%;
}

.main-bottom {
  width: 100%;
  margin-top: 20px;
}

.school-content {
  margin-bottom: 20px;
  background-color: rgb(236, 245, 255);
}

.work-content {
  margin-bottom: 20px;
  background-color: rgb(236, 245, 255);
}
.notilist :hover{
  cursor: pointer;
  color: blue;
}
.notilist{
  font-size: 14px;
}


</style>
